package com.quan.system.common.amqp.producer;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.quan.common.bean.MailBean;
import com.quan.common.constant.CommonConstant;
import com.quan.common.utils.RandomUitl;

import lombok.extern.slf4j.Slf4j;

/**
 * 消息生产端-邮件发送
 * 
 * @author yhaoquan
 *
 */
@Slf4j
@Component
public class ProducerMessageSendMail {


	@Autowired
	private RabbitTemplate rabbitTemplate;

	public void sender(MailBean mailBean) {
		log.info("==>【RabbitMQ 消息生产端】邮件发送");
		
		// 发送消息(交换机 exchange, 路由键 routingKey, 消息体内容, 消息唯一ID)
		this.rabbitTemplate.convertAndSend(
				CommonConstant.EXCHANGE_TOPIC_MAIL, 
				CommonConstant.QUEUE_TOPIC_MAIL, 
				mailBean, 
				new CorrelationData(RandomUitl.uuid()));
	}

}
